#pragma once

#include "STD_Vat.h"
#include "Elevator.h"

namespace STD_Voorbeeld_Vat {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	
	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
		//Vat STD
	public: static STD* vatSTD=NULL;
		
		//Variabelen voor de vaten
	public: vat* v1;
	public: vat* v2;
	private: System::Windows::Forms::Button^  btnRefresh;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  lblIllegal;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Label^  lblReady;

	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  lblCanceled;


	public: vat* v3;

	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//



			//Er worden hier 3 vaten gemaakt, maar in het verdere voorbeeld maar 1 gebruikt
			v1=(vat*)malloc(sizeof(vat));
			v2=(vat*)malloc(sizeof(vat));
			v3=(vat*)malloc(sizeof(vat));

			create_vat(v1);
			create_vat(v2);
			create_vat(v3);

			setToestandsLabel();
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			//Aangemaakte vaten weer verwijderen
			free(v1);
			free(v2);
			free(v3);

			if (components)
			{
				delete components;
			}
		}

	private: System::Windows::Forms::Button^  btnVatStart;
	private: System::Windows::Forms::Button^  btnStopVat;
	private: System::Windows::Forms::Button^  btnOpTemp;
	private: System::Windows::Forms::Button^  btnTijdOm;
	private: System::Windows::Forms::Button^  btnVatLeeg;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::PictureBox^  pictureBox1;
	private: System::Windows::Forms::Label^  lblToestand;

	private: System::Windows::Forms::Label^  label3;



	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->btnVatStart = (gcnew System::Windows::Forms::Button());
			this->btnStopVat = (gcnew System::Windows::Forms::Button());
			this->btnOpTemp = (gcnew System::Windows::Forms::Button());
			this->btnTijdOm = (gcnew System::Windows::Forms::Button());
			this->btnVatLeeg = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->lblToestand = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->btnRefresh = (gcnew System::Windows::Forms::Button());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->lblIllegal = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->lblReady = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->lblCanceled = (gcnew System::Windows::Forms::Label());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			this->SuspendLayout();
			// 
			// btnVatStart
			// 
			this->btnVatStart->Location = System::Drawing::Point(750, 99);
			this->btnVatStart->Name = L"btnVatStart";
			this->btnVatStart->Size = System::Drawing::Size(95, 58);
			this->btnVatStart->TabIndex = 0;
			this->btnVatStart->Text = L"Start";
			this->btnVatStart->UseVisualStyleBackColor = true;
			this->btnVatStart->Click += gcnew System::EventHandler(this, &Form1::btnVatStart_Click);
			// 
			// btnStopVat
			// 
			this->btnStopVat->Location = System::Drawing::Point(750, 163);
			this->btnStopVat->Name = L"btnStopVat";
			this->btnStopVat->Size = System::Drawing::Size(95, 58);
			this->btnStopVat->TabIndex = 1;
			this->btnStopVat->Text = L"Stop";
			this->btnStopVat->UseVisualStyleBackColor = true;
			this->btnStopVat->Click += gcnew System::EventHandler(this, &Form1::btnStopVat_Click);
			// 
			// btnOpTemp
			// 
			this->btnOpTemp->Location = System::Drawing::Point(750, 227);
			this->btnOpTemp->Name = L"btnOpTemp";
			this->btnOpTemp->Size = System::Drawing::Size(95, 58);
			this->btnOpTemp->TabIndex = 2;
			this->btnOpTemp->Text = L"OpTemp";
			this->btnOpTemp->UseVisualStyleBackColor = true;
			this->btnOpTemp->Click += gcnew System::EventHandler(this, &Form1::btnOpTemp_Click);
			// 
			// btnTijdOm
			// 
			this->btnTijdOm->Location = System::Drawing::Point(750, 291);
			this->btnTijdOm->Name = L"btnTijdOm";
			this->btnTijdOm->Size = System::Drawing::Size(95, 58);
			this->btnTijdOm->TabIndex = 3;
			this->btnTijdOm->Text = L"TijdOm";
			this->btnTijdOm->UseVisualStyleBackColor = true;
			this->btnTijdOm->Click += gcnew System::EventHandler(this, &Form1::btnTijdOm_Click);
			// 
			// btnVatLeeg
			// 
			this->btnVatLeeg->Location = System::Drawing::Point(750, 355);
			this->btnVatLeeg->Name = L"btnVatLeeg";
			this->btnVatLeeg->Size = System::Drawing::Size(95, 58);
			this->btnVatLeeg->TabIndex = 4;
			this->btnVatLeeg->Text = L"VatLeeg";
			this->btnVatLeeg->UseVisualStyleBackColor = true;
			this->btnVatLeeg->Click += gcnew System::EventHandler(this, &Form1::btnVatLeeg_Click);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label1->Location = System::Drawing::Point(746, 76);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(69, 20);
			this->label1->TabIndex = 5;
			this->label1->Text = L"Events:";
			// 
			// pictureBox1
			// 
			this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
			this->pictureBox1->Location = System::Drawing::Point(271, 45);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(432, 456);
			this->pictureBox1->TabIndex = 6;
			this->pictureBox1->TabStop = false;
			// 
			// lblToestand
			// 
			this->lblToestand->AutoSize = true;
			this->lblToestand->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->lblToestand->Location = System::Drawing::Point(38, 109);
			this->lblToestand->Name = L"lblToestand";
			this->lblToestand->Size = System::Drawing::Size(91, 20);
			this->lblToestand->TabIndex = 7;
			this->lblToestand->Text = L"lblToestand";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label3->Location = System::Drawing::Point(38, 76);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(89, 20);
			this->label3->TabIndex = 8;
			this->label3->Text = L"Toestand:";
			// 
			// btnRefresh
			// 
			this->btnRefresh->Location = System::Drawing::Point(40, 442);
			this->btnRefresh->Name = L"btnRefresh";
			this->btnRefresh->Size = System::Drawing::Size(87, 59);
			this->btnRefresh->TabIndex = 9;
			this->btnRefresh->Text = L"Refresh";
			this->btnRefresh->UseVisualStyleBackColor = true;
			this->btnRefresh->Click += gcnew System::EventHandler(this, &Form1::btnRefresh_Click);
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label2->Location = System::Drawing::Point(38, 163);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(125, 20);
			this->label2->TabIndex = 11;
			this->label2->Text = L"Illegale acties:";
			this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
			// 
			// lblIllegal
			// 
			this->lblIllegal->AutoSize = true;
			this->lblIllegal->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->lblIllegal->Location = System::Drawing::Point(38, 195);
			this->lblIllegal->Name = L"lblIllegal";
			this->lblIllegal->Size = System::Drawing::Size(51, 20);
			this->lblIllegal->TabIndex = 10;
			this->lblIllegal->Text = L"label4";
			this->lblIllegal->Click += gcnew System::EventHandler(this, &Form1::label4_Click);
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label4->Location = System::Drawing::Point(38, 247);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(176, 20);
			this->label4->TabIndex = 13;
			this->label4->Text = L"Voltooide producten:";
			// 
			// lblReady
			// 
			this->lblReady->AutoSize = true;
			this->lblReady->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->lblReady->Location = System::Drawing::Point(38, 279);
			this->lblReady->Name = L"lblReady";
			this->lblReady->Size = System::Drawing::Size(51, 20);
			this->lblReady->TabIndex = 12;
			this->lblReady->Text = L"label4";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label6->Location = System::Drawing::Point(38, 337);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(214, 20);
			this->label6->TabIndex = 15;
			this->label6->Text = L"Geannuleerde producten:";
			// 
			// lblCanceled
			// 
			this->lblCanceled->AutoSize = true;
			this->lblCanceled->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->lblCanceled->Location = System::Drawing::Point(38, 369);
			this->lblCanceled->Name = L"lblCanceled";
			this->lblCanceled->Size = System::Drawing::Size(51, 20);
			this->lblCanceled->TabIndex = 14;
			this->lblCanceled->Text = L"label4";
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(875, 560);
			this->Controls->Add(this->label6);
			this->Controls->Add(this->lblCanceled);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->lblReady);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->lblIllegal);
			this->Controls->Add(this->btnRefresh);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->lblToestand);
			this->Controls->Add(this->pictureBox1);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->btnVatLeeg);
			this->Controls->Add(this->btnTijdOm);
			this->Controls->Add(this->btnOpTemp);
			this->Controls->Add(this->btnStopVat);
			this->Controls->Add(this->btnVatStart);
			this->Name = L"Form1";
			this->Text = L"Form1";
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

	private: System::Void setToestandsLabel()
	{
		switch (v1->status)
		{
		case 0: //idle
			lblToestand->Text = "Idle"; break;
		case 1: //opwarmen
			lblToestand->Text = "Opwarmen"; break;
		case 2: //reactie
			lblToestand->Text = "Reactie"; break;
		case 3: //leegLopen		
			lblToestand->Text = "Leeg Lopen"; break;
		default: 
			lblToestand->Text = "Unknown"; break;
		}

		lblIllegal->Text = Convert::ToString(v1->illegalEvents);
		lblReady->Text = Convert::ToString(v1->readyProducts);
		lblCanceled->Text = Convert::ToString(v1->cancelledProducts);
	}

	private: System::Void btnVatStart_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		sendEvent_vat(v1, vatStart);
	}

	private: System::Void btnStopVat_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		sendEvent_vat(v1, vatStop);
	}

	private: System::Void btnOpTemp_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		sendEvent_vat(v1, vatOpTemp);
	}
	
	private: System::Void btnTijdOm_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		sendEvent_vat(v1, vatTijdOm);
	}

	private: System::Void btnVatLeeg_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		sendEvent_vat(v1, vatLeeg);
	}

	private: System::Void btnRefresh_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		setToestandsLabel();
	}
private: System::Void label2_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void label4_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
};
}

